home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 10 - 1994 / 10.10 Oct 94 / Sprocket / Lib / SplashWindow.cp < prev    next >
Encoding:
Text File  |  1994-08-25  |  1.6 KB  |  71 lines  |  [TEXT/MMCC]

  1. /*
  2.     File:        SplashWindow.cp
  3.  
  4.     Contains:    a simple splash screen window
  5.                 
  6.     Written by: Dave Falkenburg
  7.     
  8.     Copyright:    © 1993-94 by Dave Falkenburg, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.     To Do:        Add tools to the palette
  13.  */
  14.  
  15. #include <ToolUtils.h>
  16. #include <Resources.h>
  17. #include "AppLib.h"
  18. #include "SplashWindow.h"
  19.  
  20.  
  21. TSplashWindow::TSplashWindow()
  22.     {
  23.     this->CreateWindow(kNormalWindow);
  24.     }
  25.  
  26.  
  27. TSplashWindow::~TSplashWindow()
  28.     {
  29.     this->Close();
  30.     }
  31.  
  32.  
  33. WindowPtr
  34. TSplashWindow::MakeNewWindow(WindowPtr behindWindow)
  35.     {
  36.     PicHandle    splashPicture = GetPicture(kSplashPictureID);
  37.     WindowPtr    splashWindow;
  38.     GrafPtr        oldPort;
  39.     
  40.     GetPort(&oldPort);
  41.     
  42.     if (splashPicture)
  43.         {
  44.         Rect    r = (**splashPicture).picFrame;
  45.         Rect    windowRect;
  46.         
  47.         //    normalize the rectangle
  48.         OffsetRect(&r,-r.left,-r.top);
  49.  
  50.         windowRect = r;
  51.         //    center it on the main screen
  52.         OffsetRect(&windowRect,((qd.screenBits.bounds.right-r.right) >> 1),((qd.screenBits.bounds.bottom-r.bottom) >> 1));
  53.         
  54.         if (gHasColorQuickdraw)
  55.             splashWindow = NewWindow(nil,&windowRect,"\p",false,dBoxProc,behindWindow,false,(long) this);
  56.         else
  57.             splashWindow = NewCWindow(nil,&windowRect,"\p",false,dBoxProc,behindWindow,false,(long) this);
  58.  
  59.         DetachResource((Handle) splashPicture);        // need to do so we don’t botch the resource map after closing
  60.         SetWindowPic(splashWindow,splashPicture);    // in case an Alert comes up
  61.         ShowWindow(splashWindow);
  62.         SetPort(splashWindow);
  63.         BeginUpdate(splashWindow);                    //    avoid a flashing update event later
  64.             DrawPicture(splashPicture,&r);
  65.         EndUpdate(splashWindow);                    //    avoid a flashing update event later
  66.         }
  67.  
  68.     SetPort(oldPort);
  69.     return splashWindow;
  70.     }
  71.